﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using RedDragon.Common.Dtos;
using RedDragon.ERP.API.Application.Commands.MaterialManagements;
using T.Common.Domain.Common;

namespace RedDragon.ERP.API.Controllers
{
    /// <summary>
    /// 物料管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MaterialManagementsController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public MaterialManagementsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 物料管理添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateMaterialManagement(CreateMaterialManagementCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 物料管理显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<List<MaterialDto>>> SearchMaterialManagement([FromQuery] SearchMaterialManagementCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 物料类别树形添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateMaterialCategory(CreateMaterialCategoryCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 物料类别树形显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearcMaterialCategory([FromQuery]SearchMaterialCategoryCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 物料服务显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchMaterialsServices([FromQuery] SearchMaterialsServicesCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 物料单位显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchMaterialUnit([FromQuery] SearchMaterialUnitCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 规格单位显示列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> SearchSpecificationUnit([FromQuery] SearchSpecificationUnitCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
